home *** CD-ROM | disk | FTP | other *** search
- Path: mudskipper.cac.psu.edu!user
- From: fcusack@tdx.org (frank.)
- Newsgroups: comp.lang.c
- Subject: Re: simple code, argc, ar
- Date: Sat, 03 Feb 1996 16:55:27 -0400
- Organization: Penn State University, Center for Academic Computing
- Message-ID: <fcusack-0302961655270001@mudskipper.cac.psu.edu>
- References: <4eurnq$8oc@gail.ripco.com>
- NNTP-Posting-Host: mudskipper.cac.psu.edu
-
- In article <4eurnq$8oc@gail.ripco.com>, mambuhl@ripco.com (Martin Ambuhl) wrote:
-
- > otisg@panther.middlebury.edu (Otis Gospodnetic)
- > in <11f7cc$17261a.3b3@daprez> asks:
- >
- > [snip]
- > >Problem - I am doing something wrong and I almost always end up calling
- > >Usage() even if I use the program correctly.
- >
- > [snip]
- > > if (!strcmp(argv[1],"-d") || !strcmp(argv[1],"-e")) {
- > > Usage();
- > Suppose arv[1] is "-d", then this is
- > if (1 /* || !strcmp(argv[1],"-e") */) ...
- > Suppose argv[2] is "-e", then it is
- > if (0 || 1) ...
- >
- > Only when argv[1] is neither "-d" nor "-e" is Usage() called.
-
- Actually, your example proves the opposite - when argv[1] is "-e" or "-d"
- Usage() is called.
-
- >
- > Try
- > > if (strcmp(argv[1],"-d") && strcmp(argv[1],"-e")) {
-
- good! A lot better than my double negative comparison in a differnet followup
- ~Frank
- -- I am Pentium of Borg. Division is futile. You will be approximated. --
- -- If you build it, they will come --> http://www.tdx.org/~fcusack/ --
- -- PGP key fingerprint: 01 C0 C0 B9 CC 78 67 0F 3F 64 80 65 8B 0F F9 EA --
-